﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CoreEx.Common.Proxy;
using LinFu.AOP.Interfaces;
using LinFu.IoC.Configuration;
using LinFu.IoC.Interfaces;
using LinFu.Proxy.Interfaces;

namespace CoreEx.Common.Implementation.Proxy
{
    [Implements(typeof(IConstructorInterceptor), ServiceName = "InterceptorInjector")]
    public class InterceptorInjector : IConstructorInterceptor
    {
        private readonly Func<IInterceptor> _interceptorFactory;

        public InterceptorInjector(Func<IInterceptor> interceptorFactory)
        {
            _interceptorFactory = interceptorFactory;
        }

        public void Intercept(IInitalizationInfo info)
        {
            ((IProxy) info.Target).Interceptor = _interceptorFactory();
        }

        
    }
}
